<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>URI Functions</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2">
<link rel="start" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-utilities.html" title="GLib Utilities">
<link rel="prev" href="glib-File-Utilities.html" title="File Utilities">
<link rel="next" href="glib-Shell-related-Utilities.html" title="Shell-related Utilities">
<meta name="generator" content="GTK-Doc V1.9 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="glib.html" title="GLib Overview">
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
<link rel="chapter" href="tools.html" title="GLib Tools">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
<link rel="index" href="ix09.html" title="Index of new symbols in 2.14">
<link rel="index" href="ix10.html" title="Index of new symbols in 2.16">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-File-Utilities.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-Shell-related-Utilities.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3178834" class="shortcut">Top</a>
                  &#160;|&#160;
                  <a href="#id3179030" class="shortcut">Description</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="glib-URI-Functions"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id3178834"></a><span class="refentrytitle">URI Functions</span>
</h2>
<p>URI Functions &#8212; URI Functions</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">

#include &lt;glib.h&gt;


#define             <a class="link" href="glib-URI-Functions.html#G-URI-RESERVED-CHARS-ALLOWED-IN-PATH:CAPS">G_URI_RESERVED_CHARS_ALLOWED_IN_PATH</a>
#define             <a class="link" href="glib-URI-Functions.html#G-URI-RESERVED-CHARS-ALLOWED-IN-PATH-ELEMENT:CAPS">G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT</a>
#define             <a class="link" href="glib-URI-Functions.html#G-URI-RESERVED-CHARS-ALLOWED-IN-USERINFO:CAPS">G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO</a>
#define             <a class="link" href="glib-URI-Functions.html#G-URI-RESERVED-CHARS-GENERIC-DELIMITERS:CAPS">G_URI_RESERVED_CHARS_GENERIC_DELIMITERS</a>
#define             <a class="link" href="glib-URI-Functions.html#G-URI-RESERVED-CHARS-SUBCOMPONENT-DELIMITERS:CAPS">G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS</a>
char*               <a class="link" href="glib-URI-Functions.html#g-uri-parse-scheme">g_uri_parse_scheme</a>                  (const char *uri);
char*               <a class="link" href="glib-URI-Functions.html#g-uri-escape-string">g_uri_escape_string</a>                 (const char *unescaped,
                                                         const char *reserved_chars_allowed,
                                                         <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> allow_utf8);
char*               <a class="link" href="glib-URI-Functions.html#g-uri-unescape-string">g_uri_unescape_string</a>               (const char *escaped_string,
                                                         const char *illegal_characters);
char*               <a class="link" href="glib-URI-Functions.html#g-uri-unescape-segment">g_uri_unescape_segment</a>              (const char *escaped_string,
                                                         const char *escaped_string_end,
                                                         const char *illegal_characters);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id3179030"></a><h2>Description</h2>
<p>
Functions for manipulating Universal Resource Identifiers (URIs) as 
defined by RFC 3986. It is highly recommended that you have read and
understand RFC 3986 for understanding this API. A copy of RFC 3986 
can be found at <a class="ulink" href="http://www.ietf.org/rfc/rfc3986.txt" target="_top">http://www.ietf.org/rfc/rfc3986.txt</a>.</p>
<p>

</p>
</div>
<div class="refsect1" lang="en">
<a name="id3179056"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id3179067"></a><h3>
<a name="G-URI-RESERVED-CHARS-ALLOWED-IN-PATH:CAPS"></a>G_URI_RESERVED_CHARS_ALLOWED_IN_PATH</h3>
<a class="indexterm" name="id3179081"></a><pre class="programlisting">#define G_URI_RESERVED_CHARS_ALLOWED_IN_PATH G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT "/"
</pre>
<p>
Allowed characters in a path. Includes "!$&amp;'()*+,;=:@/".</p>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3179102"></a><h3>
<a name="G-URI-RESERVED-CHARS-ALLOWED-IN-PATH-ELEMENT:CAPS"></a>G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT</h3>
<a class="indexterm" name="id3179117"></a><pre class="programlisting">#define G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":@"
</pre>
<p>
Allowed characters in path elements. Includes "!$&amp;'()*+,;=:@".</p>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3179139"></a><h3>
<a name="G-URI-RESERVED-CHARS-ALLOWED-IN-USERINFO:CAPS"></a>G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO</h3>
<a class="indexterm" name="id3179154"></a><pre class="programlisting">#define G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":"
</pre>
<p>
Allowed characters in userinfo as defined in RFC 3986. Includes "!$&amp;'()*+,;=:".</p>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3179176"></a><h3>
<a name="G-URI-RESERVED-CHARS-GENERIC-DELIMITERS:CAPS"></a>G_URI_RESERVED_CHARS_GENERIC_DELIMITERS</h3>
<a class="indexterm" name="id3179190"></a><pre class="programlisting">#define G_URI_RESERVED_CHARS_GENERIC_DELIMITERS ":/?#[]@"
</pre>
<p>
Generic delimiters characters as defined in RFC 3986. Includes ":/?#[]@".</p>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3179210"></a><h3>
<a name="G-URI-RESERVED-CHARS-SUBCOMPONENT-DELIMITERS:CAPS"></a>G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS</h3>
<a class="indexterm" name="id3179225"></a><pre class="programlisting">#define G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS "!$&amp;'()*+,;="
</pre>
<p>
Subcomponent delimiter characters as defined in RFC 3986. Includes "!$&amp;'()*+,;=".</p>
<p>

</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3179248"></a><h3>
<a name="g-uri-parse-scheme"></a>g_uri_parse_scheme ()</h3>
<a class="indexterm" name="id3179263"></a><pre class="programlisting">char*               g_uri_parse_scheme                  (const char *uri);</pre>
<p>
Gets the scheme portion of a URI string. RFC 3986 decodes the scheme as:
</p>
<pre class="programlisting">
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] 
</pre>
<p>
Common schemes include "file", "http", "svn+ssh", etc.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>uri</code></em>&#160;:</span></p></td>
<td> a valid URI.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> The "Scheme" component of the URI, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. 
The returned string should be freed when no longer needed.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3179351"></a><h3>
<a name="g-uri-escape-string"></a>g_uri_escape_string ()</h3>
<a class="indexterm" name="id3179366"></a><pre class="programlisting">char*               g_uri_escape_string                 (const char *unescaped,
                                                         const char *reserved_chars_allowed,
                                                         <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> allow_utf8);</pre>
<p>
Escapes a string for use in a URI.
</p>
<p>
Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
characters plus dash, dot, underscore and tilde) are escaped.
But if you specify characters in <em class="parameter"><code>reserved_chars_allowed</code></em> they are not
escaped. This is useful for the "reserved" characters in the URI
specification, since those are allowed unescaped in some portions of
a URI.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>unescaped</code></em>&#160;:</span></p></td>
<td> the unescaped input string.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>reserved_chars_allowed</code></em>&#160;:</span></p></td>
<td> a string of reserved characters that are
     allowed to be used.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>allow_utf8</code></em>&#160;:</span></p></td>
<td> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the result can include UTF-8 characters.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> an escaped version of <em class="parameter"><code>unescaped</code></em>. The returned string should be 
freed when no longer needed.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3179512"></a><h3>
<a name="g-uri-unescape-string"></a>g_uri_unescape_string ()</h3>
<a class="indexterm" name="id3179527"></a><pre class="programlisting">char*               g_uri_unescape_string               (const char *escaped_string,
                                                         const char *illegal_characters);</pre>
<p>
Unescapes a whole escaped string.
</p>
<p>
If any of the characters in <em class="parameter"><code>illegal_characters</code></em> or the character zero appears
as an escaped character in <em class="parameter"><code>escaped_string</code></em> then that is an error and <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
will be returned. This is useful it you want to avoid for instance having a
slash being expanded in an escaped path element, which might confuse pathname
handling.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>escaped_string</code></em>&#160;:</span></p></td>
<td> an escaped string to be unescaped.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>illegal_characters</code></em>&#160;:</span></p></td>
<td> an optional string of illegal characters not to be allowed.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> an unescaped version of <em class="parameter"><code>escaped_string</code></em>. The returned string 
should be freed when no longer needed.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3179656"></a><h3>
<a name="g-uri-unescape-segment"></a>g_uri_unescape_segment ()</h3>
<a class="indexterm" name="id3179672"></a><pre class="programlisting">char*               g_uri_unescape_segment              (const char *escaped_string,
                                                         const char *escaped_string_end,
                                                         const char *illegal_characters);</pre>
<p>
Unescapes a segment of an escaped string.
</p>
<p>
If any of the characters in <em class="parameter"><code>illegal_characters</code></em> or the character zero appears
as an escaped character in <em class="parameter"><code>escaped_string</code></em> then that is an error and <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>
will be returned. This is useful it you want to avoid for instance having a
slash being expanded in an escaped path element, which might confuse pathname
handling.</p>
<p>

</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>escaped_string</code></em>&#160;:</span></p></td>
<td> a string.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>escaped_string_end</code></em>&#160;:</span></p></td>
<td> a string.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>illegal_characters</code></em>&#160;:</span></p></td>
<td> an optional string of illegal characters not to be allowed.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td>
<td> an unescaped version of <em class="parameter"><code>escaped_string</code></em> or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error.
The returned string should be freed when no longer needed.

</td>
</tr>
</tbody>
</table></div>
<p class="since">Since  2.16
</p>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id3179834"></a><div class="refsect2" lang="en"><a name="id3179835"></a></div>
<hr>
<div class="refsect2" lang="en"><a name="id3179836"></a></div>
</div>
</div>
</body>
</html>
